package edu.cmu.cs.webapp.ioms.ui.providers.product;

import java.text.DateFormat;

import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;

import edu.cmu.cs.webapp.ioms.models.Product;
import edu.cmu.cs.webapp.ioms.models.PurchaseOrder;
import edu.cmu.cs.webapp.ioms.models.OrderStatus;
import edu.cmu.cs.webapp.ioms.utils.IOMSImageHelper;
import edu.cmu.cs.webapp.ioms.utils.IOMSImages;

public class ProductListTableViewerLableProvider extends ColumnLabelProvider
		implements ITableLabelProvider {

	public static final int PRODUCT_ID = 0;
	public static final int PRODCUT_NAME = 1;
	public static final int PRODUCT_PRICE = 2;
	public static final int PRODUCT_DESCRIPTION=3;

	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		if (element != null) {
			if (columnIndex == PRODUCT_ID) {
				return IOMSImageHelper.getInstance().getImage(
						IOMSImages.IMG_PROD);
			}
		}
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang
	 * .Object, int)
	 */
	@Override
	public String getColumnText(Object element, int columnIndex) {
		if (element instanceof Product) {
			Product product = (Product) element;
			switch (columnIndex) {
			case PRODUCT_ID:
				// id
				return "" + String.valueOf(product.getProd_id());
			case PRODCUT_NAME:
				// PurchaseOrder status
				return product.getProd_name();
			case PRODUCT_PRICE:
				// PurchaseOrder date
				return String.valueOf(product.getPrice());
				
			case PRODUCT_DESCRIPTION:
				return product.getProd_description();
			default:
				return "";
			}
		}

		return "";

	}

}
